import BaseView from "../../../cfw/mvc/BaseView";
import ToiletController from "../ToiletController";


const { ccclass, property } = cc._decorator;

@ccclass
export default class ToiletDoorView extends BaseView {


    // @property(cc.Sprite)
    // open: cc.Sprite = null;

    @property(cc.Sprite)
    door: cc.Sprite = null;


    protected controller:ToiletController;
    private step:number = 0;
    start() {
        cc.tween(this.door.node).repeat(2, cc.tween(this.door.node).by(0.2, { angle: 5 }).by(0.2, { angle: -5 })).start();
    }

    onButtonDoorClick() {
        if(this.step == 0){
            this.door.node.active = false;
            // this.open.node.active = true;
            cc.tween(this).to(1, {}).call(this.finish.bind(this)).start();
        }

    }
    onButtonHomeClick(){
        this.controller.gotoLobby()
    }
    finish() {
        this.controller.intoRoom()
    }

}
